//
//  IMCustomModel.m
//  Btpin
//
//  Created by Vic on 2019/4/22.
//  Copyright © 2019 Vic. All rights reserved.
//

#import "IMCustomModel.h"

@implementation IMCustomModel

- (void)setValuesForKeysWithDictionary:(NSDictionary<NSString *,id> *)keyedValues {
    self.type = [UIToolsControl dataAnalysis:keyedValues[@"type"]];
    self.style = [UIToolsControl dataAnalysis:keyedValues[@"style"]];
    self.title = [UIToolsControl dataAnalysis:keyedValues[@"title"]];
    self.content = [UIToolsControl dataAnalysis:keyedValues[@"content"]];
    self.rid = [UIToolsControl dataAnalysis:keyedValues[@"rid"]];
    self.resume_id = [UIToolsControl dataAnalysis:keyedValues[@"resume_id"]];
    self.id = [UIToolsControl dataAnalysis:keyedValues[@"id"]];
    self.expire_time = [UIToolsControl dataAnalysis:keyedValues[@"expire_time"]];
    
    self.info = [[MineBusinessCardBaseModel alloc] init];
    self.jobInfoModel = [[IMJobBaseInfoModel alloc] init];
    self.personalInfoModel = [[IMPersonalBaseInfoModel alloc] init];
    if (self.type && [self.type isEqualToString:@"namecard"]) {
        if (keyedValues[@"info"] && [keyedValues[@"info"] isKindOfClass:[NSDictionary class]]) {
            [self.info setValuesForKeysWithDictionary:keyedValues[@"info"]];
        }
    } else if (self.type && [self.type isEqualToString:@"resume_info"]) {
        if (keyedValues[@"info"] && [keyedValues[@"info"] isKindOfClass:[NSDictionary class]]) {
            [self.personalInfoModel setValuesForKeysWithDictionary:keyedValues[@"info"]];
        }
    } else if (self.type && [self.type isEqualToString:@"job_info"]) {
        if (keyedValues[@"info"] && [keyedValues[@"info"] isKindOfClass:[NSDictionary class]]) {
            [self.jobInfoModel setValuesForKeysWithDictionary:keyedValues[@"info"]];
        }
        
    }
    
    
    self.actions = [NSMutableArray arrayWithCapacity:0];
    if (keyedValues[@"actions"] && [keyedValues[@"actions"] isKindOfClass:[NSArray class]] && [keyedValues[@"actions"] count]) {
        for (NSDictionary *dic in keyedValues[@"actions"]) {
            [self.actions addObject:dic];
        }
    }
}

- (void)setValue:(id)value forUndefinedKey:(NSString *)key {
    
}

- (id)copyWithZone:(NSZone *)zone {
    IMCustomModel *model = [[[self class] allocWithZone:zone] init];
    model.type = self.type;
    model.style = self.style;
    model.title = self.title;
    model.content = self.content;
    model.rid = self.rid;
    model.resume_id = self.resume_id;
    model.expire_time = self.expire_time;
    model.id = self.id;
    
    model.info = [[MineBusinessCardBaseModel alloc] init];
    model.info = [self.info copy];
    model.actions = [NSMutableArray arrayWithCapacity:0];
    if (self.actions.count) {
        for (NSDictionary *dic in self.actions) {
            [model.actions addObject:dic];
        }
    }
    
    return model;
}

@end
